<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
        <title>安装maven私服 - 负责和大饼的博客</title><meta name="Description" content="想专注于学点手艺"><meta property="og:title" content="安装maven私服" />
<meta property="og:description" content="安装maven私服 安装nexus 下载nexus repository oss 解压缩，进入bin目录，执行nexus /run ，启动nexus 访问 http://localhost:8081 进入nexus，初始用户是a" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://amath0312.github.com/install_nexus/" />
<meta property="article:published_time" content="2019-09-15T16:57:17+08:00" />
<meta property="article:modified_time" content="2019-09-15T16:57:17+08:00" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="安装maven私服"/>
<meta name="twitter:description" content="安装maven私服 安装nexus 下载nexus repository oss 解压缩，进入bin目录，执行nexus /run ，启动nexus 访问 http://localhost:8081 进入nexus，初始用户是a"/>
<meta name="application-name" content="负责和大饼的博客">
<meta name="apple-mobile-web-app-title" content="负责和大饼的博客"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="https://amath0312.github.com/install_nexus/" /><link rel="prev" href="https://amath0312.github.com/logback_config/" /><link rel="next" href="https://amath0312.github.com/mybatis-generator-code-read/" /><link rel="stylesheet" href="/lib/normalize/normalize.min.css"><link rel="stylesheet" href="/css/style.min.css"><link rel="stylesheet" href="/lib/fontawesome-free/all.min.css"><link rel="stylesheet" href="/lib/animate/animate.min.css"><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "安装maven私服",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https:\/\/amath0312.github.com\/install_nexus\/"
        },"genre": "posts","keywords": "maven, 私服","wordcount":  817 ,
        "url": "https:\/\/amath0312.github.com\/install_nexus\/","datePublished": "2019-09-15T16:57:17+08:00","dateModified": "2019-09-15T16:57:17+08:00","publisher": {
            "@type": "Organization",
            "name": "负责和大饼"},"author": {
                "@type": "Person",
                "name": "负责和大饼"
            },"description": ""
    }
    </script></head>
    <body header-desktop="" header-mobile=""><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title="负责和大饼的博客">负责和大饼的博客</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> Blog </a><a class="menu-item" href="/categories/"> Categories </a><a class="menu-item" href="/tags/"> Tags </a><a class="menu-item" href="/about/"> About </a><span class="menu-item delimiter"></span><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder="Search titles or contents..." id="search-input-desktop">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="Search">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="Clear">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </span><a href="javascript:void(0);" class="menu-item theme-switch" title="Switch Theme">
                    <i class="fas fa-adjust fa-fw"></i>
                </a>
            </div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title="负责和大饼的博客">负责和大饼的博客</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder="Search titles or contents..." id="search-input-mobile">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="Search">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="Clear">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </div>
                    <a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
                        Cancel
                    </a>
                </div><a class="menu-item" href="/posts/" title="">Blog</a><a class="menu-item" href="/categories/" title="">Categories</a><a class="menu-item" href="/tags/" title="">Tags</a><a class="menu-item" href="/about/" title="">About</a><a href="javascript:void(0);" class="menu-item theme-switch" title="Switch Theme">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">Contents</h2>
            <div class="toc-content" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animated flipInX">安装maven私服</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="/" title="Author" rel=" author" class="author"><i class="fas fa-user-circle fa-fw"></i>负责和大饼</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2019-09-08">2019-09-08</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;817 words&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;2 minutes&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>Contents</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li><a href="#安装nexus">安装nexus</a></li>
    <li><a href="#配置maven">配置maven</a>
      <ul>
        <li><a href="#设置settingsxml">设置<code>settings.xml</code></a></li>
      </ul>
    </li>
    <li><a href="#配置项目">配置项目</a>
      <ul>
        <li><a href="#创建parent项目">创建parent项目</a></li>
        <li><a href="#创建log子项目">创建log子项目</a></li>
        <li><a href="#创建core子项目">创建core子项目</a></li>
        <li><a href="#创建service子项目">创建service子项目</a></li>
      </ul>
    </li>
    <li><a href="#版本发布">版本发布</a></li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><h1 id="安装maven私服">安装maven私服</h1>
<h2 id="安装nexus">安装nexus</h2>
<ol>
<li>下载<a href="http://sonatype.com/download-nexus-repo-oss" target="_blank" rel="noopener noreffer">nexus repository oss</a></li>
<li>解压缩，进入bin目录，执行<code>nexus /run</code> ，启动nexus</li>
<li>访问 <a href="http://localhost:8081" target="_blank" rel="noopener noreffer">http://localhost:8081</a> 进入nexus，初始用户是<code>admin</code>，初始密码在<code>admin.password</code>文件中</li>
<li>登录成功后，设置<code>maven-releases</code>和<code>maven-snapshots</code>的发布策略为<code>Allow redeploy</code></li>
<li>设置<code>maven-public</code>的member，如图：
<img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/amath0312/blog/raw/master/static/images/resource/%E5%AE%89%E8%A3%85maven%E7%A7%81%E6%9C%8D/1568536017970.png"
        data-srcset="https://gitee.com/amath0312/blog/raw/master/static/images/resource/%E5%AE%89%E8%A3%85maven%E7%A7%81%E6%9C%8D/1568536017970.png, https://gitee.com/amath0312/blog/raw/master/static/images/resource/%E5%AE%89%E8%A3%85maven%E7%A7%81%E6%9C%8D/1568536017970.png 1.5x, https://gitee.com/amath0312/blog/raw/master/static/images/resource/%E5%AE%89%E8%A3%85maven%E7%A7%81%E6%9C%8D/1568536017970.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/amath0312/blog/raw/master/static/images/resource/%E5%AE%89%E8%A3%85maven%E7%A7%81%E6%9C%8D/1568536017970.png"
        title="maven_public_members" /></li>
<li>创建<code>deploy</code>角色，权限包含<code>maven-central</code>、<code>maven-public</code>、<code>maven-releases</code>、<code>maven-snapshots</code>相关的全部操作权限</li>
<li>创建用户dep，角色为<code>deploy</code></li>
</ol>
<h2 id="配置maven">配置maven</h2>
<h3 id="设置settingsxml">设置<code>settings.xml</code></h3>
<div class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml"><span class="cp">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span class="nt">&lt;settings</span> <span class="na">xmlns=</span><span class="s">&#34;http://maven.apache.org/SETTINGS/1.0.0&#34;</span>
	<span class="na">xmlns:xsi=</span><span class="s">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
	<span class="na">xsi:schemaLocation=</span><span class="s">&#34;http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd&#34;</span><span class="nt">&gt;</span>
	<span class="c">&lt;!-- 本地仓库路径 --&gt;</span>
    <span class="nt">&lt;localRepository&gt;</span>~/.m2/repository<span class="nt">&lt;/localRepository&gt;</span>

	<span class="nt">&lt;pluginGroups&gt;&lt;/pluginGroups&gt;</span>
	<span class="nt">&lt;proxies&gt;&lt;/proxies&gt;</span>

	<span class="c">&lt;!-- 设置nexus部署用户的用户名和密码, release和snapshot与项目的pom文件对应 --&gt;</span>
	<span class="nt">&lt;servers&gt;</span>
		<span class="nt">&lt;server&gt;</span>
			<span class="nt">&lt;id&gt;</span>release<span class="nt">&lt;/id&gt;</span>
			<span class="nt">&lt;username&gt;</span>zhaolin<span class="nt">&lt;/username&gt;</span>
			<span class="nt">&lt;password&gt;</span>zhaolin<span class="nt">&lt;/password&gt;</span>
		<span class="nt">&lt;/server&gt;</span>
		<span class="nt">&lt;server&gt;</span>
			<span class="nt">&lt;id&gt;</span>snapshot<span class="nt">&lt;/id&gt;</span>
			<span class="nt">&lt;username&gt;</span>zhaolin<span class="nt">&lt;/username&gt;</span>
			<span class="nt">&lt;password&gt;</span>zhaolin<span class="nt">&lt;/password&gt;</span>
		<span class="nt">&lt;/server&gt;</span>
	<span class="nt">&lt;/servers&gt;</span>

	<span class="c">&lt;!-- 配置镜像，请求全部发送给nexus私服，url为maven-public的路径 --&gt;</span>
	<span class="nt">&lt;mirrors&gt;</span>
		<span class="nt">&lt;mirror&gt;</span>
			<span class="nt">&lt;id&gt;</span>private_repo<span class="nt">&lt;/id&gt;</span>
			<span class="nt">&lt;mirrorOf&gt;</span>*<span class="nt">&lt;/mirrorOf&gt;</span>
			<span class="nt">&lt;name&gt;</span>private repository<span class="nt">&lt;/name&gt;</span>
			<span class="nt">&lt;url&gt;</span>http://192.168.0.102:8081/repository/maven-public/<span class="nt">&lt;/url&gt;</span>
		<span class="nt">&lt;/mirror&gt;</span>
	<span class="nt">&lt;/mirrors&gt;</span>

	<span class="nt">&lt;profiles&gt;</span>
		<span class="nt">&lt;profile&gt;</span>
			<span class="nt">&lt;id&gt;</span>private_repo<span class="nt">&lt;/id&gt;</span>
			<span class="nt">&lt;repositories&gt;</span>
				<span class="nt">&lt;repository&gt;</span>
					<span class="nt">&lt;id&gt;</span>private<span class="nt">&lt;/id&gt;</span>
					<span class="nt">&lt;name&gt;</span>Central Repository<span class="nt">&lt;/name&gt;</span>
					<span class="nt">&lt;url&gt;</span>http://private_repo<span class="nt">&lt;/url&gt;</span>
					<span class="nt">&lt;layout&gt;</span>default<span class="nt">&lt;/layout&gt;</span>
					<span class="nt">&lt;snapshots&gt;</span>
						<span class="nt">&lt;enabled&gt;</span>true<span class="nt">&lt;/enabled&gt;</span>
					<span class="nt">&lt;/snapshots&gt;</span>
					<span class="nt">&lt;releases&gt;</span>
						<span class="nt">&lt;enabled&gt;</span>true<span class="nt">&lt;/enabled&gt;</span>
					<span class="nt">&lt;/releases&gt;</span>
				<span class="nt">&lt;/repository&gt;</span>
			<span class="nt">&lt;/repositories&gt;</span>
		<span class="nt">&lt;/profile&gt;</span>
	<span class="nt">&lt;/profiles&gt;</span>
	<span class="nt">&lt;activeProfiles&gt;</span>
		<span class="nt">&lt;activeProfile&gt;</span>private_repo<span class="nt">&lt;/activeProfile&gt;</span>
	<span class="nt">&lt;/activeProfiles&gt;</span>
<span class="nt">&lt;/settings&gt;</span>

</code></pre></div><h2 id="配置项目">配置项目</h2>
<blockquote>
<p>本文模拟多模块项目的场景
项目结构如下：
./sample-log/
./sample-core/
./sample-service/
./pom.xml</p>
</blockquote>
<h3 id="创建parent项目">创建parent项目</h3>
<blockquote>
<p>项目名称为sample-parent, pom文件内容如下：</p>
</blockquote>
<div class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml"><span class="cp">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span class="nt">&lt;project</span> <span class="na">xmlns=</span><span class="s">&#34;http://maven.apache.org/POM/4.0.0&#34;</span>
         <span class="na">xmlns:xsi=</span><span class="s">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
         <span class="na">xsi:schemaLocation=</span><span class="s">&#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&#34;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;modelVersion&gt;</span>4.0.0<span class="nt">&lt;/modelVersion&gt;</span>

    <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
    <span class="nt">&lt;artifactId&gt;</span>sample-parent<span class="nt">&lt;/artifactId&gt;</span>
    <span class="nt">&lt;packaging&gt;</span>pom<span class="nt">&lt;/packaging&gt;</span>
    <span class="nt">&lt;version&gt;</span>1.0<span class="nt">&lt;/version&gt;</span>

    <span class="nt">&lt;properties&gt;</span>
        <span class="nt">&lt;project.build.sourceEncoding&gt;</span>UTF-8<span class="nt">&lt;/project.build.sourceEncoding&gt;</span>

        <span class="nt">&lt;maven.compiler.source&gt;</span>1.8<span class="nt">&lt;/maven.compiler.source&gt;</span>
        <span class="nt">&lt;maven.compiler.target&gt;</span>1.8<span class="nt">&lt;/maven.compiler.target&gt;</span>
        <span class="nt">&lt;maven.compiler.compilerVersion&gt;</span>1.8<span class="nt">&lt;/maven.compiler.compilerVersion&gt;</span>
        <span class="nt">&lt;arguments/&gt;</span>
    <span class="nt">&lt;/properties&gt;</span>

    <span class="nt">&lt;modules&gt;</span>
        <span class="nt">&lt;module&gt;</span>sample-log<span class="nt">&lt;/module&gt;</span>
        <span class="nt">&lt;module&gt;</span>sample-core<span class="nt">&lt;/module&gt;</span>
        <span class="nt">&lt;module&gt;</span>sample-service<span class="nt">&lt;/module&gt;</span>
    <span class="nt">&lt;/modules&gt;</span>

	<span class="c">&lt;!-- 发布仓库配置，与上文中的&#39;servers&#39;对应 --&gt;</span>
    <span class="nt">&lt;distributionManagement&gt;</span>
        <span class="nt">&lt;repository&gt;</span>
            <span class="nt">&lt;id&gt;</span>release<span class="nt">&lt;/id&gt;</span>
            <span class="nt">&lt;url&gt;</span>http://192.168.0.102:8081/repository/maven-releases/<span class="nt">&lt;/url&gt;</span>
        <span class="nt">&lt;/repository&gt;</span>
        <span class="nt">&lt;snapshotRepository&gt;</span>
            <span class="nt">&lt;id&gt;</span>snapshot<span class="nt">&lt;/id&gt;</span>
            <span class="nt">&lt;url&gt;</span>http://192.168.0.102:8081/repository/maven-snapshots/<span class="nt">&lt;/url&gt;</span>
        <span class="nt">&lt;/snapshotRepository&gt;</span>
    <span class="nt">&lt;/distributionManagement&gt;</span>

    <span class="nt">&lt;dependencyManagement&gt;</span>
        <span class="nt">&lt;dependencies&gt;</span>
            <span class="nt">&lt;dependency&gt;</span>
                <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
                <span class="nt">&lt;artifactId&gt;</span>sample-log<span class="nt">&lt;/artifactId&gt;</span>
                <span class="nt">&lt;version&gt;</span>${project.version}<span class="nt">&lt;/version&gt;</span>
            <span class="nt">&lt;/dependency&gt;</span>
            <span class="nt">&lt;dependency&gt;</span>
                <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
                <span class="nt">&lt;artifactId&gt;</span>sample-core<span class="nt">&lt;/artifactId&gt;</span>
                <span class="nt">&lt;version&gt;</span>${project.version}<span class="nt">&lt;/version&gt;</span>
            <span class="nt">&lt;/dependency&gt;</span>
            <span class="nt">&lt;dependency&gt;</span>
                <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
                <span class="nt">&lt;artifactId&gt;</span>sample-service<span class="nt">&lt;/artifactId&gt;</span>
                <span class="nt">&lt;version&gt;</span>${project.version}<span class="nt">&lt;/version&gt;</span>
            <span class="nt">&lt;/dependency&gt;</span>
    <span class="nt">&lt;/dependencyManagement&gt;</span>
    <span class="nt">&lt;build&gt;</span>
        <span class="nt">&lt;plugins&gt;</span>
		    <span class="c">&lt;!-- 用于批量更新版本号 --&gt;</span>
            <span class="nt">&lt;plugin&gt;</span>
                <span class="nt">&lt;groupId&gt;</span>org.codehaus.mojo<span class="nt">&lt;/groupId&gt;</span>
                <span class="nt">&lt;artifactId&gt;</span>versions-maven-plugin<span class="nt">&lt;/artifactId&gt;</span>
                <span class="nt">&lt;version&gt;</span>2.3<span class="nt">&lt;/version&gt;</span>
                <span class="nt">&lt;configuration&gt;</span>
                    <span class="nt">&lt;generateBackupPoms&gt;</span>false<span class="nt">&lt;/generateBackupPoms&gt;</span>
                <span class="nt">&lt;/configuration&gt;</span>
            <span class="nt">&lt;/plugin&gt;</span>
        <span class="nt">&lt;/plugins&gt;</span>
    <span class="nt">&lt;/build&gt;</span>
<span class="nt">&lt;/project&gt;</span>
</code></pre></div><h3 id="创建log子项目">创建log子项目</h3>
<div class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml"><span class="cp">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span class="nt">&lt;project</span> <span class="na">xmlns=</span><span class="s">&#34;http://maven.apache.org/POM/4.0.0&#34;</span>
         <span class="na">xmlns:xsi=</span><span class="s">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
         <span class="na">xsi:schemaLocation=</span><span class="s">&#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&#34;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;parent&gt;</span>
        <span class="nt">&lt;artifactId&gt;</span>sample-parent<span class="nt">&lt;/artifactId&gt;</span>
        <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
        <span class="nt">&lt;version&gt;</span>1.0<span class="nt">&lt;/version&gt;</span>
        <span class="nt">&lt;relativePath&gt;</span>../pom.xml<span class="nt">&lt;/relativePath&gt;</span>
    <span class="nt">&lt;/parent&gt;</span>
    <span class="nt">&lt;modelVersion&gt;</span>4.0.0<span class="nt">&lt;/modelVersion&gt;</span>

    <span class="nt">&lt;artifactId&gt;</span>sample-log<span class="nt">&lt;/artifactId&gt;</span>

    <span class="nt">&lt;dependencies&gt;&lt;/dependencies&gt;</span>
<span class="nt">&lt;/project&gt;</span>
</code></pre></div><h3 id="创建core子项目">创建core子项目</h3>
<div class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml"><span class="cp">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span class="nt">&lt;project</span> <span class="na">xmlns=</span><span class="s">&#34;http://maven.apache.org/POM/4.0.0&#34;</span>
         <span class="na">xmlns:xsi=</span><span class="s">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
         <span class="na">xsi:schemaLocation=</span><span class="s">&#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&#34;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;parent&gt;</span>
        <span class="nt">&lt;artifactId&gt;</span>sample-parent<span class="nt">&lt;/artifactId&gt;</span>
        <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
        <span class="nt">&lt;version&gt;</span>1.0<span class="nt">&lt;/version&gt;</span>
        <span class="nt">&lt;relativePath&gt;</span>../pom.xml<span class="nt">&lt;/relativePath&gt;</span>
    <span class="nt">&lt;/parent&gt;</span>
    <span class="nt">&lt;modelVersion&gt;</span>4.0.0<span class="nt">&lt;/modelVersion&gt;</span>

    <span class="nt">&lt;artifactId&gt;</span>sample-core<span class="nt">&lt;/artifactId&gt;</span>

    <span class="nt">&lt;dependencies&gt;</span>
        <span class="nt">&lt;dependency&gt;</span>
            <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
            <span class="nt">&lt;artifactId&gt;</span>sample-log<span class="nt">&lt;/artifactId&gt;</span>
        <span class="nt">&lt;/dependency&gt;</span>
    <span class="nt">&lt;/dependencies&gt;</span>
<span class="nt">&lt;/project&gt;</span>
</code></pre></div><h3 id="创建service子项目">创建service子项目</h3>
<div class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml"><span class="cp">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span class="nt">&lt;project</span> <span class="na">xmlns=</span><span class="s">&#34;http://maven.apache.org/POM/4.0.0&#34;</span>
         <span class="na">xmlns:xsi=</span><span class="s">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
         <span class="na">xsi:schemaLocation=</span><span class="s">&#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&#34;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;parent&gt;</span>
        <span class="nt">&lt;artifactId&gt;</span>sample-parent<span class="nt">&lt;/artifactId&gt;</span>
        <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
        <span class="nt">&lt;version&gt;</span>1.0<span class="nt">&lt;/version&gt;</span>
        <span class="nt">&lt;relativePath&gt;</span>../pom.xml<span class="nt">&lt;/relativePath&gt;</span>
    <span class="nt">&lt;/parent&gt;</span>
    <span class="nt">&lt;modelVersion&gt;</span>4.0.0<span class="nt">&lt;/modelVersion&gt;</span>

    <span class="nt">&lt;artifactId&gt;</span>sample-service<span class="nt">&lt;/artifactId&gt;</span>

    <span class="nt">&lt;dependencies&gt;</span>
        <span class="nt">&lt;dependency&gt;</span>
            <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
            <span class="nt">&lt;artifactId&gt;</span>sample-log<span class="nt">&lt;/artifactId&gt;</span>
        <span class="nt">&lt;/dependency&gt;</span>
        <span class="nt">&lt;dependency&gt;</span>
            <span class="nt">&lt;groupId&gt;</span>beer.coder.mvn.sample<span class="nt">&lt;/groupId&gt;</span>
            <span class="nt">&lt;artifactId&gt;</span>sample-core<span class="nt">&lt;/artifactId&gt;</span>
        <span class="nt">&lt;/dependency&gt;</span>
<span class="nt">&lt;/project&gt;</span>
</code></pre></div><h2 id="版本发布">版本发布</h2>
<ol>
<li>执行<code>mvn clean deploy</code>，打包并发布版本</li>
<li>进入nexus，查看<code>maven-releases</code>中新增了<code>sample-*</code>项目，说明发布成功</li>
<li>执行<code>mvn versions:set -DnewVersion=1.1</code>，可以批量更新版本号</li>
</ol>
</div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>Updated on 2019-09-08</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"></div>
            <div class="post-info-share">
                <span></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw"></i>&nbsp;<a href="/tags/maven/">maven</a>,&nbsp;<a href="/tags/%E7%A7%81%E6%9C%8D/">私服</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">Back</a></span>&nbsp;|&nbsp;<span><a href="/">Home</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/logback_config/" class="prev" rel="prev" title="logback加载指定配置文件"><i class="fas fa-angle-left fa-fw"></i>logback加载指定配置文件</a>
            <a href="/mybatis-generator-code-read/" class="next" rel="next" title="MyBatis Generator 源码笔记">MyBatis Generator 源码笔记<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
</article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">Powered by <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.75.1">Hugo</a> | Theme - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw"></i> LoveIt</a>
                </div><div class="footer-line"><i class="far fa-copyright fa-fw"></i><span itemprop="copyrightYear">2019 - 2020</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/" target="_blank"></a></span>&nbsp;|&nbsp;<span class="license">本文采用<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/" target="_blank">知识共享署名-非商业性使用 4.0 国际许可协议</a>进行许可</span></div>
        </div>
    </footer></div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="Back to Top">
                <i class="fas fa-arrow-up fa-fw"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="View Comments">
                <i class="fas fa-comment fa-fw"></i>
            </a>
        </div><script type="text/javascript" src="/lib/smooth-scroll/smooth-scroll.min.js"></script><script type="text/javascript" src="/lib/autocomplete/autocomplete.min.js"></script><script type="text/javascript" src="/lib/algoliasearch/algoliasearch-lite.umd.min.js"></script><script type="text/javascript" src="/lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="/lib/clipboard/clipboard.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"Copy to clipboard","maxShownLines":10},"comment":{},"search":{"algoliaAppID":"JJRDOPDPLW","algoliaIndex":"amath_blog","algoliaSearchKey":"e529bedc6a3af35b53e2597f1c7550c2","highlightTag":"em","maxResultLength":10,"noResultsFound":"No results found","snippetLength":50,"type":"algolia"}};</script><script type="text/javascript" src="/js/theme.min.js"></script></body>
</html>
